<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
    <!--{include file='comm/header.tpl'}-->
    <title>商品详情</title>
    <!--{include file='comm/comm_editor.tpl'}-->
    <style>
        html{
            overflow-y:scroll;
            overflow:-moz-scrollbars-vertical;
        }
        * {
    	font-size: 99%;
    	margin: 0;
    	padding: 0;
		}
        .detailTable{
            border:1px solid #D4C6C6;
            border-collapse: collapse;
        }
        .title_td{
            background:#A5CBBD;
            border:1px solid #BCB4B7;
            padding:5px 0 5px 5px;
        }

        .msg_td{
            border:1px solid #BCB4B7;
            padding:5px 0 5px 5px;
        }
		.pointsByFlg{
			margin-top:13px;
		}
        .hotkinds{float:left;width:99%;margin-top:2px;margin-left:1%;height:auto;overflow:hidden;}
        .dl_hotkinds{margin:0 5px;padding:5px 0 0;height:28px;background:#FCFAF4;}
        .dl_hotkinds_1{margin:0 5px;padding:5px 0 0;height:28px;background:#ececec;}
        .dl_hotkinds_2{margin:0 5px;padding:5px 0 0;height:28px;}
        .dt_hotkinds{float:left;width:90px;height:22px;line-height:22px;text-align:left;margin-right:2px;display:inline;font-size:0.9pm;font-weight:bold;overflow:hidden;white-space:nowrap;}
        .dl_hotkinds dd{line-height:22px;}
        .list_nowrap{float:left;overflow:hidden;white-space:nowrap;}
        .div_header{background:#FFFFFF;border:1px solid #fff;}

    </style>
</head>

<body style="overflow-y:hidden;">
<div class="select-box" style="margin:0px 15px 0px 15px;">
    <div onclick="goods.change(1);" id="select_1" class="selected">
        商品基本信息
    </div>
    <div onclick="goods.change(2);" id="select_2">
        商品规格
    </div>
    <div onclick="goods.change(3);" id="select_3">
        商品图片和描述
    </div>
    <div onclick="goods.change(4);" id="select_4">
        商品关键字
    </div>
    <div onclick="goods.change(5);" id="select_5">
        商品标签
    </div>
    <div onclick="goods.change(6);" id="select_6">
        商品扩展属性
    </div>
</div>
<div style="width:100%">

    <form name="goodsEdit_form_1" id="goodsEdit_form_1">
	    <div class="items clearfix">
	        <h2 style="" class="tal">商品基本信息</h2>
	        <div class="items2">
		        <!--{if isset($error_msg)}-->
		            <div class="error-box">
		                <!--{$error_msg}-->
		            </div>
				<!--{else}-->
					<div>
						<div class="allTextTime" style="padding-bottom:10px;float:left;">

							<div style="margin:8px 0" class="input-group">
								<span style="width: 110px;" class="input-group-addon">商品名称：</span>
								<span placeholder="商品名称" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->goodsName}--></span>
							</div>
							
							<div style="margin:8px 0" class="input-group">
								<span style="width: 110px;" class="input-group-addon">商品品牌：</span>
								<span placeholder="商品品牌" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->brandName}--></span>
							</div>
							<div style="margin:8px 0" class="input-group">
								<span style="width: 110px;" class="input-group-addon">商品单位：</span>
								<span placeholder="商品单位" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->unitName}--></span>
							</div>
							<div style="margin:8px 0" class="input-group">
								<span style="width: 110px;" class="input-group-addon">商品保质期：</span>
								<span placeholder="商品保质期" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->shelfLife}--></span>
							</div>
							<div style="margin:8px 0;" class="input-group">
					            <span style="width:110px;" class="input-group-addon">商品简述：</span>
					            <span placeholder="商品简述" class="form-control hasDatepicker" disabled style="height:80px;padding-left:8px;"><!--{$goodsInfo->brief}--></span>
					        </div>
					        <div style="margin:8px 0;" class="input-group">
					            <span style="width:110px;" class="input-group-addon">商品备注：</span>
					            <span placeholder="商品备注" class="form-control hasDatepicker" disabled style="height:80px;padding-left:8px;"><!--{$goodsInfo->memo}--></span>
					        </div>
							<div style="margin:8px 0" class="input-group">
								<span style="width: 110px;" class="input-group-addon">等级折扣：</span>
								<span placeholder="等级折扣" class="form-control hasDatepicker" disabled style="padding-left:8px;">
									<!--{$goodsInfo->levelName}-->
								</span>
							</div>
						</div>
						<div class="goodsImg" style="float:right;border:1px solid #E0E0E0;height:240px;width:240px;margin:8px 18px 0px 0px;">
							<!--{if isset($goodsInfo->goodsMainPic) && $goodsInfo->goodsMainPic != ''}-->
				            	<img class="bigImgCss"  src="<!--{$goodsInfo->goodsMainPic}-->" style="width:240px;height:240px;border:0px;" />
				            <!--{/if}-->
						</div>
						<div style="clear:both;"></div>
					</div>
				
		        <!--{/if}-->
	        </div>
	    </div>
	    <div style="margin-top:30px;"></div>
	</form>    

	<form name="goodsEdit_form_2" id="goodsEdit_form_2" style="display:none;">
    	<div class="items clearfix">
            <h2 class="tal">商品规格</h2>
            <div class="allTextTime" style="padding:10px 0px 10px 10px;">
				<div style="margin:8px 0" class="input-group">
					<span style="width: 110px;" class="input-group-addon">市场价：</span>
					<span placeholder="市场价" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->marketPrice|default:''}--></span>
				</div>
				
				<div style="margin:8px 0" class="input-group">
					<span style="width: 110px;" class="input-group-addon">销售价：</span>
					<span placeholder="销售价" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->salePrice|default:''}--></span>
				</div>
				
				<div style="margin:8px 0" class="input-group">
					<span style="width: 110px;" class="input-group-addon">商品重量(KG)：</span>
					<span placeholder="商品重量" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->goodsWeight|default:''}--></span>
				</div>
				
				<div style="margin:8px 0" class="input-group">
					<span style="width: 110px;" class="input-group-addon">库存：</span>
					<span placeholder="库存" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->goodsStock|default:''}--></span>
				</div>
				
				<div style="margin:8px 0" class="input-group">
					<span style="width: 110px;" class="input-group-addon">商家编码：</span>
					<span placeholder="商家编码" class="form-control hasDatepicker" disabled style="padding-left:8px;"><!--{$goodsInfo->extendCode|default:''}--></span>
				</div>	
				
				<div class="extend_category">
					<!--{if isset($category_relation)}-->
						<!--{foreach from=$category_relation item=relation}-->
							<div style="margin:8px 0" class="input-group">
								<span style="width: 110px;" class="input-group-addon">商品分类：</span>
								<span placeholder="商品分类" class="form-control hasDatepicker" disabled style="padding-left:8px;">
									<!--{$relation->bigName}--> =》<!--{$relation->midName}--> 
									<!--{if $relation->samllName != ''}-->
										=》<!--{$relation->samllName}-->
									<!--{/if}-->
									
								</span>
							</div>
						<!--{/foreach}-->
					<!--{else}-->
						<div style="margin:8px 0" class="input-group">
							<span style="width: 110px;" class="input-group-addon">商品分类：</span>
							<span placeholder="商品分类" class="form-control hasDatepicker" disabled style="padding-left:8px;">
								<!--{$goodsInfo->bigCategoryName}--> =》<!--{$goodsInfo->midCategoryName}--> 
								<!--{if $goodsInfo->smallCategoryName != ''}-->
									=》<!--{$goodsInfo->smallCategoryName}-->
								<!--{/if}-->
							</span>
						</div>	
					<!--{/if}-->
				</div>
			</div>
        </div>	
    </form>	

    <form name="goodsEdit_form_3" id="goodsEdit_form_3" style="display:none;">
	    <div class="items clearfix">
	        <h2 style="" class="tal">商品展示图片</h2>
	        <div class="items2">
	
	            <table>
	                <tr>
	                    <td style="width:20%;">
	                        <div style="width:100%;">
	                            <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
	                                <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                    <!--{if $pic->sortOrder == 1}-->
	                                        <image src="<!--{$pic->imgsrc}-->" id="img_1" style="width:100%;height:100%;" ></image>
	                                    <!--{/if}-->
	                                <!--{/foreach}-->
	                            </div>
	                            <div style="padding-top:5px;text-align: center;">
	                                
	                                    <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                        <!--{if $pic->sortOrder == 1}-->
	                                            <input type="hidden"  name="hidImg_1" id="hidImg_1" value="<!--{$pic->pictureLink}-->" >
	                                        <!--{/if}-->
	                                    <!--{/foreach}-->
	                            </div>
	                        </div>
	                    </td>
	                    <td style="width:20%;padding-left: 20px;">
	                        <div style="width:100%;">
	                            <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
	                                <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                    <!--{if $pic->sortOrder == 2}-->
	                                        <image src="<!--{$pic->imgsrc}-->" id="img_2" style="width:100%;height:100%;" ></image>
	                                    <!--{/if}-->
	                                <!--{/foreach}-->
	                            </div>
	                            <div style="padding-top:5px;text-align: center;">
	                                
	                                    <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                        <!--{if $pic->sortOrder == 2}-->
	                                             <input type="hidden"  name="hidImg_2" id="hidImg_2" value="<!--{$pic->pictureLink}-->" >
	                                        <!--{/if}-->
	                                    <!--{/foreach}-->
	                            </div>
	                        </div>
	                    </td>
	                    <td style="width:20%;padding-left: 20px;">
	                        <div style="width:100%;">
	                            <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
	                                <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                    <!--{if $pic->sortOrder == 3}-->
	                                        <image src="<!--{$pic->imgsrc}-->" id="img_3" style="width:100%;height:100%;" ></image>
	                                    <!--{/if}-->
	                                <!--{/foreach}-->
	                            </div>
	                            <div style="padding-top:5px;text-align: center;">
	                                
	                                    <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                        <!--{if $pic->sortOrder == 3}-->
	                                            <input type="hidden" name="hidImg_3" id="hidImg_3" value="<!--{$pic->pictureLink}-->" >
	                                        <!--{/if}-->
	                                    <!--{/foreach}-->
	                            </div>
	                        </div>
	                    </td>
	                    <td style="width:20%;padding-left: 20px;">
	                        <div style="width:100%;">
	                            <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
	                                <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                    <!--{if $pic->sortOrder == 4}-->
	                                        <image src="<!--{$pic->imgsrc}-->" id="img_4" style="width:100%;height:100%;" ></image>
	                                    <!--{/if}-->
	                                <!--{/foreach}-->
	                            </div>
	                            <div style="padding-top:5px;text-align: center;">
	                                
	                                    <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                        <!--{if $pic->sortOrder == 4}-->
	                                            <input type="hidden" name="hidImg_4" id="hidImg_4" value="<!--{$pic->pictureLink}-->" >
	                                        <!--{/if}-->
	                                    <!--{/foreach}-->
	                            </div>
	                        </div>
	                    </td>
	                    <td style="width:20%;padding-left: 20px;">
	                        <div style="width:100%;">
	                            <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
	                                <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                    <!--{if $pic->sortOrder == 5}-->
	                                        <image src="<!--{$pic->imgsrc}-->" id="img_5" style="width:100%;height:100%;" ></image>
	                                    <!--{/if}-->
	                                <!--{/foreach}-->
	
	                            </div>
	                            <div style="padding-top:5px;text-align: center;">
	                                
	                                    <!--{foreach from=$goodsInfo->picArray item=pic}-->
	                                        <!--{if $pic->sortOrder == 5}-->
	                                            <input type="hidden" name="hidImg_5" id="hidImg_5" value="<!--{$pic->pictureLink}-->" >
	                                        <!--{/if}-->
	                                    <!--{/foreach}-->
	                            </div>
	                        </div>
	                    </td>
	                </tr>
	            </table>
	        </div>
	    </div>
	
	    <div class="items clearfix">
	        <h2 style="" class="tal">商品详细描述</h2>
	        <div class="items2">
	            <div>
	                <textarea name="description" id="description" style="width:100%;height:400px;visibility:hidden;"><!--{$goodsInfo->description}--></textarea>
	            </div>
	        </div>
	    </div>
	    
		<div class="items clearfix">
	        <h2 style="" class="tal">底部模板</h2>
	        <div class="items2" style="overflow:hidden;padding-bottom:40px;">
	            <div>
	          		 <div style="width:200px;height:180px;float:left;margin-left:10px;">
	                    <div style="width:100%;height:150px;border:1px solid #E2D9D9;"></div>
	                </div>
	                
	                <!--{foreach from=$goodsInfo->templates item=t_l}-->
	                	<div style="width:200px;height:180px;float:left;margin-left:10px;">
		                    <div style="width:100%;height:150px;border:1px solid #E2D9D9;overflow:hidden;">
		                    	<!--{$t_l->description}-->
		                    </div>
			            </div>
	                <!--{/foreach}-->
	            </div>
	        </div>
	    </div>
	    <div style="margin-top:50px;"></div>
    </form>

	<form name="goodsEdit_form_4" id="goodsEdit_form_4" style="display:none;">
	    <div class="items clearfix">
	        <h2 style="" class="tal">商品关键字</h2>
	        <div class="items2">
	            <div>
	                <table class="dl_hotkinds" id="js_hotkinds" style="width:100%;background:#FFFFFF"">
	                    <tr>
	                        <td id="keywordList">
	                           <!--{foreach from=$goodsInfo->keyword item=k_l}-->								
									<div style="width:450px;height:30px;background:#FFFFFF;margin-left:18px;" class="list_nowrap">
										<!--{$k_l->keyword}-->
									</div>
								<!--{/foreach}-->	
	                        </td>
	                    </tr>
	                </table>
	            </div>
	        </div>
	    </div>
	</form>

	<form name="goodsEdit_form_5" id="goodsEdit_form_5" style="display:none;">
        <div class="items clearfix">
            <h2 style="" class="tal">商品标签</h2>
            <div class="items2" style="padding:0px;">

                <input type="hidden" id="goodsID" name="goodsID" value="<!--{$goodsInfo->goodsID}-->">
                <!--{assign var="tag_group_id" value=0}-->
                <!--{assign var="group_count" value=0}-->
                <!--{assign var="cnt" value = 1}-->
                    <!--{foreach from=$goodsInfo->tagArray item =tag_line}-->
                    <!--{if $tag_group_id == 0 }-->
                <dl id="js_hotkinds" class="dl_hotkinds">
                    <dt class="dt_hotkinds" style="width:105px;text-align:center;" title="<!--{$tag_line->tagGroupName}--> - <!--{$tag_line->memoName}-->">
                        <!--{$tag_line->memoName}-->
                    </dt>
                <dd>
                    <!--{assign var="tag_group_id" value=$tag_line->tagGroupID}-->
                        <!--{/if}-->

                    <!--{if $tag_group_id!= 0 && $tag_group_id != $tag_line->tagGroupID}-->
                    <!--{assign var="tag_group_id" value=$tag_line->tagGroupID}-->
                    <!--{assign var="group_count" value=0}-->
                    <!--{assign var="cnt" value = $cnt+1}-->
                </dd>
                </dl>
                    <dl id="js_hotkinds" <!--{if $cnt%2 == 0}--> class="dl_hotkinds_1"<!--{else}--> class="dl_hotkinds"<!--{/if}-->>
                    <dt class="dt_hotkinds" style="width:105px;text-align:center;" title="<!--{$tag_line->tagGroupName}--> - <!--{$tag_line->memoName}-->">
                        <!--{$tag_line->memoName}-->
                    </dt>
                <dd>
                        <!--{/if}-->
                    <!--{if $group_count!=0 && $group_count%8 == 0}-->
                </dd>
                    </dl>
                    <dl id="js_hotkinds" <!--{if $cnt%2 == 0}--> class="dl_hotkinds_1" <!--{else}--> class="dl_hotkinds" <!--{/if}-->>
                    <dt class="dt_hotkinds" style="width:105px;text-align:center;">&nbsp;</dt>
                <dd>
                    <!--{assign var="group_count" value=0}-->
                        <!--{/if}-->
                <!--{assign var="group_count" value=$group_count+1}-->
                <div class="list_nowrap" style="width:105px;" title="<!--{$tag_line->tagName}-->">
                    <input disabled type="checkbox" id="chk_<!--{$tag_line->tagID}-->" name="tag" value="<!--{$tag_line->tagGroupID}-->_<!--{$tag_line->tagID}-->" <!--{if $tag_line->checkFlg==1}-->checked<!--{/if}-->>
                    <!--{$tag_line->tagName}-->
                </div>
                    <!--{/foreach}-->
            </dd>
                </dl>
            </div>
        </div>
    </form>

    <form name="goodsEdit_form_6" id="goodsEdit_form_6" style="display:none;">

        <div class="items clearfix">
            <h2 style="" class="tal">商品扩展属性</h2>
            <div class="items2">
                <div>
                    <table class="dl_hotkinds" id="js_hotkinds" style="width:100%;background:#FFFFFF">
                        <tr>
                            <td id="keywordReamList">

                                <!--{foreach from = $extend_data item = val}-->
                                &nbsp;&nbsp;
                                <div style="width:450px;height:30px;background:#FFFFFF" class="list_nowrap">
                                    <!--{$val->name}--> - <!--{$val->value}-->
                                </div>
                                <!--{/foreach}-->

                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>

    </form>
</div>

<div style="width:450px;height:30px;background:#FFFFFF" class="list_nowrap"></div>     
</body>
</html>

<script type="text/javascript">

	window.editor = KindEditor.create("#description");

    var postID = '<!--{$goodsInfo->postID}-->';
    var flg = 1;

//    $("#flex").flexigrid({
//        url:"/invokingAjax-backend/goods/goodsEdit.ajax?operFlg=3&twoPostID=<!--{$goodsInfo->postID}-->&xjx=none&useFlg=1",
//        dataType: "json",
//        colModel : [
//        {display: "商品SKU",  width : 100},
//        {display: "商品名称", width : 320},
//        {display: "市场价", width : 100},
//        {display: "销售价", width : 100},
//        {display: "商品重量", width : 100},
//        {display: "库存", width : 100},
//		{display: "商家编码", width : 100,align:"center"}
//        ],
//        sortname: "",
//        sortorder: "",
//        rp: 30,
//        useRp: true,
//        showTableToggleBtn: true
//    });

    //保存信息流转方法
    function saveThisto(){

        if( flg == 1 ){
            goods.savegoodsInfo();
        }else if ( flg == 2 ){
            goods.savegoodsSku();
        }else if ( flg == 3 ){
            goods.savegoodsPic();
        }else if ( flg == 4 ){
            goods.savegoodsKeyWords();
        }else if ( flg == 5 ){
            goods.savegoodsTag();
        }
    }

    var goods = {
    	
    	synchronizationFlg : 0, //同步标示

        //同步
        synchronization:function(){
        	goods.synchronizationFlg = 1;
        	saveThisto();
        },

        change: function(index){
        	$('[id^=select_]').removeClass('selected');
        	$('#select_'+index).addClass('selected');
        	
        	$('[id^=goodsEdit_form_]').hide();
        	$('#goodsEdit_form_'+index).show();
        	
        	flg = index;
        },

        //上传图片
        uploadPic:function( flg ){
            E.open("/quanliadmin/app/uploads/goodsImage.php?flg=" + flg, "上传", {height: 200,width: 800, top: 50, left: 150});
        },

        //删除商品图片
        deletePic:function( flg ){
            var html = "<img src='' id='img_"+flg+"' style='width:100%;height:100%;'>";
            $('#img_' + flg).after(html).remove();
            $('#hidImg_' + flg).val('');
        },

        //显示图片
        showImage:function( imageUrl , flg ){
            $('#img_' + flg).attr('src', '/quanliadmin/docroot/images/goods/' + imageUrl);
            $('#hidImg_' + flg).val(imageUrl);
        },

        addList:function( obj ){

            if( obj.code == 200 ){

                var params = obj.data;

                var html = '<option value="">请选择</option>';

                for(var i=0; i<params.length; i++){
                    html += '<option value="' + params[i].id + '">' + params[i].name + '</option>';
                }

                if( Flg == 1 ){
                    $("#midCategoryID").html(html);
                }else if ( Flg == 2 ){
                    $("#smallCategoryID").html(html);
                }

            }else{
                E.alert('系统错误，请与管理员联系');
            }

        },

        //保存商品基本信息
        savegoodsInfo:function(){
        	var error_msg = "" ;
        	var goodsName = $.trim($("#goodsName").val()) ;
        	
        	if(goodsName == "")
        		error_msg += "商品名称不能为空</br>" ;
        		
        	if(error_msg != "") {
        		E.alert(error_msg);
        		return false ;
        	}

            var dt = $('#goodsEdit_form_'+flg).serializeArray();
            var a = {name:'postID',value:postID};
            var b = {name:'flg',value:1};
            dt.push(a);
            dt.push(b);
            jquery_ajax(4,dt,goods.back);
        },
        
        savegoodsSku : function(){
        	var skuFlg = 0;
        	$('[name*=post_]').each(function(k,v){
        		var currentVal = E.trim($(v).val());
        		if(currentVal == '' || currentVal == null){
        			E.alert('商品sku不能为空');
        			skuFlg = 1;
        			return false;
        		}
        	});
        	
        	if(skuFlg == 1)
        		return false;
        	
        	var dt = $('#goodsEdit_form_'+flg).serializeArray();
        	var a = {name:'postID',value:postID};
            var b = {name:'flg',value:2};
            dt.push(a);
            dt.push(b);
        	jquery_ajax(4,dt,goods.back);
        },

        //保存商品图片
        savegoodsPic:function(){
            editor.sync();
            var dt = $('#goodsEdit_form_'+flg).serializeArray();
            var description = $("#description").val();
            var a = {name:'postID',value:postID};
            var b = {name:'flg',value:3};
            var c = {name:'description',value:description};
            dt.push(a);
            dt.push(b);
            dt.push(c);
            jquery_ajax(4,dt,goods.back);
        },

        //保存商品关键字
        savegoodsKeyWords:function(){
            var data = new Array();

            $("input[name='addedKeywords']").each(function(k,v){
                var value = v.value;
                var t = v.checked;

                if( t == true ){
                    data.push(value);
                }

            })

            if( data.length == 0 ){
                E.alert('请先添加关键字');
            }else{
                jquery_ajax(4,{postID:postID,flg:4,params:data},goods.back);
            }
        },

        //保存商品标签
        savegoodsTag:function(){

            var data = new Array();

            $("input[name='tag']").each(function(k,v){
                var value = v.value;
                var t = v.checked;

                if( t == true ){
                    data.push(value);
                }

            })

            if( data.length == 0 ){
                E.alert('请先选择标签');
            }else{
                jquery_ajax(4,{postID:postID,flg:5,params:data},goods.back);
            }

        },

        //保存调价信息
        save_goodsPrice:function(){
            var dt = $('#changePrice_form').serializeArray();
            var marketPrice = E.trim( $("#marketPrice").val() );
            var salePrice   = E.trim( $("#salePrice").val() );
            var addPoints   = E.trim( $("#addPoints").val() );
            var pointPrice  = E.trim( $("#pointPrice").val() );
            var salePoints  = E.trim( $("#salePoints").val() );
            var error_msg = '';

            if( marketPrice != '' ){
                if( !E.isMoney(marketPrice) )
                    error_msg += '市场价格式错误<br>';
            }

            if( salePrice != '' ){
                if( !E.isMoney(salePrice) )
                    error_msg += '销售价格式错误<br>';
            }

            if(  addPoints != '' ){
                if( !E.isInt(addPoints) )
                    error_msg += '兑换积分必须为正整数<br>';
            }

            if(  pointPrice != '' ){
                if( !E.isMoney(pointPrice) )
                    error_msg += '兑换金额格式有误<br>';
            }

            if(  salePoints && !E.isInt(salePoints) ){
                error_msg += '赠送积分必须为正整数<br>';
            }

            if( error_msg != '' ){

                E.alert(error_msg);

            }else{

                var a = {name:'postID',value:postID};
                dt.push(a);
                jquery_ajax(5,dt,goods.back);

            }

        },

        //回调函数
        back:function( obj ){

            if( obj.code == 200 ){
            	
            	if (goods.synchronizationFlg == 1) {
            		goods.synchronizationFlg = 0;
            		jquery_ajax(7,{postID:postID},goods.back);
            	} else {
            	
	                E.alert( obj.message , 2 , 'goods.load');
	                E.opener("goods.load");
            	}
            }else{
                E.alert(obj.message);
            }

        },

        load:function(){
        	goods.change(flg);
        },
		
		edit_productcade: function(product_code,postID,goodsID){
            var product_code = product_code;

            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/goods/goodsEdit.ajax?operFlg=10&xjx=none&useFlg=1",
                dataType: "JSON",
                data: {"product_code" : product_code},
                success: function( result_obj ) {
                    if (result_obj.code == 200) { 
                        E.popup.open({
                            title: "商家编码", //弹出标题，不传则默认为“提示信息”【可选】
                            content: result_obj.message,    //显示内容（html代码），不传则默认为空【可选】
                            css : 'width:800px;',
                            btnCall: "goods.codesubmit(\'"+product_code+"\',"+postID+","+goodsID+");" //点击“确认”按钮触发的函数/方法
                        });

                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });

        },
        codesubmit: function(product_code,postID,goodsID){
            var code_arr = Array();

            if( $("#addcodeList").html() != '' ){

                $("input[name='addcode']:checked").each(function(){

                    var objValue = $(this).val();
                    code_arr.push(objValue);

                })

                $.ajax({
                    type: "POST",
                    url: "/invokingAjax-backend/goods/goodsEdit.ajax?operFlg=11&product_code="+product_code,
                    dataType: "JSON",
                    data: {"code_arr" : code_arr,'postID':postID,'goodsID':goodsID},
                    success: function( result_obj ) {
                        if (result_obj.code == 200) {
                            E.alert(result_obj.message,2);
                        } else {
                            E.alert(result_obj.message);
                        }
                    }
                });

				E.popup.close();

            }else{
                E.alert('请输入商品编号');
            }

        },
        
        //保存等级折扣
        discountSave : function(){
        	
        	var changeLevel = $('[name=changeLevel]:checked');
        	var level = $('[name=level]:checked');
        	var discountStr = '';

        	if(changeLevel.val() != 1 && changeLevel.val() != 2 && changeLevel.val() != 3){
        		E.alert('请选择等级折扣');
        		return false;
        	}

        	if((changeLevel.val() == 1 || changeLevel.val() == 3) && (changeLevel.length < 1 || level.length < 1)){
        		E.alert('请选择等级折扣');
        		return false;
        	}
        	
        	if(changeLevel.val() == 1)
        		discountStr = '1';
        	else if(changeLevel.val() == 2)
        		discountStr = '0';
        	else{
        		$.each(level,function(k,v){
        			var v = $(v).val();
        			if(v == 1)
        				v = 100;
        				
        			discountStr += ',' + v;
        		})
        		
        		discountStr = discountStr.substr(1);
        	}

			jquery_ajax(6,{discountStr:discountStr,postID:postID},goods.back);
        },
        
        changeRaido : function(flg){
        	var isAll = '&nbsp;&nbsp;',isNo = '&nbsp;&nbsp;',isSection = '&nbsp;&nbsp;';
       		<!--{foreach from=$cust_rank item=rank}-->
            	isAll += '<input type="checkbox" name="level" id="<!--{$rank->rankID}-->" value="<!--{$rank->rankID}-->" checked disabled> <!--{$rank->rankName}--> &nbsp;&nbsp;';
            	isNo += '<input type="checkbox" name="level" id="<!--{$rank->rankID}-->" value="<!--{$rank->rankID}-->" disabled> <!--{$rank->rankName}--> &nbsp;&nbsp;';
            	isSection += '<input type="checkbox" name="level" id="<!--{$rank->rankID}-->" value="<!--{$rank->rankID}-->"> <!--{$rank->rankName}--> &nbsp;&nbsp;';
            <!--{/foreach}-->

        	if(flg == 1)	//全部是
        		$('#checkboxTd').html(isAll);
        	else if(flg == 2)	//全部否
        		$('#checkboxTd').html(isNo);
        	else
        		$('#checkboxTd').html(isSection);
        }
    }

    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/goods/goodsEdit.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                alert('网络不给力，请重新尝试...');
            }
        });
    }

    //编辑等级折扣弹出层
    function open_editLevel(){
    	var html_str = '';
    		html_str += '<table class="detailTable" style="width:100% font-size:99%;border:0px;">';
            html_str += '<tr>';
                html_str += '<td colspan="2" style="height:50px;">';
                    html_str += '&nbsp;&nbsp;';
                    <!--{if $goodsInfo->discountFlg == 1}-->
                    	html_str += '<input type="radio" name="changeLevel" value="1" onclick="goods.changeRaido(1);" checked /> 全部是&nbsp;&nbsp;';
	                    html_str += '<input type="radio" name="changeLevel" value="2" onclick="goods.changeRaido(2);" /> 全部否&nbsp;&nbsp;';
	                    html_str += '<input type="radio" name="changeLevel" value="3" onclick="goods.changeRaido(3);" /> 部分';
                    <!--{elseif $goodsInfo->discountFlg == 0}-->
                    	html_str += '<input type="radio" name="changeLevel" value="1" onclick="goods.changeRaido(1);" /> 全部是&nbsp;&nbsp;';
	                    html_str += '<input type="radio" name="changeLevel" value="2" onclick="goods.changeRaido(2);" checked /> 全部否&nbsp;&nbsp;';
	                    html_str += '<input type="radio" name="changeLevel" value="3" onclick="goods.changeRaido(3);" /> 部分';
                    <!--{else}-->
                    	html_str += '<input type="radio" name="changeLevel" value="1" onclick="goods.changeRaido(1);" /> 全部是&nbsp;&nbsp;';
	                    html_str += '<input type="radio" name="changeLevel" value="2" onclick="goods.changeRaido(2);" /> 全部否&nbsp;&nbsp;';
	                    html_str += '<input type="radio" name="changeLevel" value="3" onclick="goods.changeRaido(3);" checked /> 部分';;
                    <!--{/if}-->
                html_str += '</td>';
            html_str += '</tr>';
            html_str += '<tr>';
                html_str += '<td colspan="2" style="height:40px;word-wrap: break-word;" id="checkboxTd">';
                	html_str += '&nbsp;&nbsp;';
               		<!--{foreach from=$cust_rank item=rank}-->
               			<!--{if $goodsInfo->discountFlg == 1}-->
                    		html_str += '<input type="checkbox" name="level" id="<!--{$rank->rankID}-->" value="<!--{$rank->rankID}-->" checked disabled> <!--{$rank->rankName}--> &nbsp;&nbsp;';
						<!--{elseif $goodsInfo->discountFlg == 0}-->
							html_str += '<input type="checkbox" name="level" id="<!--{$rank->rankID}-->" value="<!--{$rank->rankID}-->" disabled> <!--{$rank->rankName}--> &nbsp;&nbsp;';
						<!--{else}-->
							<!--{if $rank->chkFlg == 1}-->
								html_str += '<input type="checkbox" name="level" id="<!--{$rank->rankID}-->" value="<!--{$rank->rankID}-->" checked> <!--{$rank->rankName}--> &nbsp;&nbsp;';
							<!--{else}-->
								html_str += '<input type="checkbox" name="level" id="<!--{$rank->rankID}-->" value="<!--{$rank->rankID}-->"> <!--{$rank->rankName}--> &nbsp;&nbsp;';
							<!--{/if}-->
							
						<!--{/if}-->
                    <!--{/foreach}-->
                html_str += '</td>';
            html_str += '</tr>';
        html_str += '</table>';
    	
    	E.popup.open({
            title: "编辑等级折扣",
            content: html_str,
            btnName: "保存",
            css : 'width:600px;',
            btnCall: "goods.discountSave()"
        });
    }

    //添加关键词
    function addKeyWords(){
        var keyWord = $("#keyWord").val();

        if( keyWord == '' ){
            E.alert('请输入关键字');
            return false;
        }

        //校验加入的关键字是否已经添加
        var exist = false;

        if( $("#keywordList").html() != '' ){

            $("input[name='addedKeywords']").each(function(){

                var objValue = $(this).val();

                if( objValue == keyWord ){
                    E.alert('关键字「' + objValue + '」已存在');
                    exist = true;
                }
            })

        }
        
        if( !exist ){
            document.getElementById('keywordList').innerHTML += '&nbsp;&nbsp;' +
            '<div style="width:450px;height:30px;background:#FFFFFF" class="list_nowrap">' +
            '<input type="checkbox" checked name="addedKeywords" value="' + keyWord + '">' + keyWord + "</div>";
            $("#keyWord").val("") ;
           
        }
		 $("#keyWord").select();
    }
	
	//添加商品编号
    function addproductcode(){
        var code = $("#code").val();

        if( code == '' ){
            E.alert('请输入商品编号');
            return false;
        }

        //校验加入的关键字是否已经添加
        var exist = false;

        if( $("#addcodeList").html() != '' ){

            $("input[name='addcode']").each(function(){

                var objValue = $(this).val();

                if( objValue == code ){
                    E.alert('商品编号「' + objValue + '」已存在');
                    exist = true;
                }
            })

        }
        
        $('#noData').remove();

        if( !exist ){
            document.getElementById('addcodeList').innerHTML += '&nbsp;&nbsp;' +
                    '<div style="width:100%;height:30px;float:left;background:#FFFFFF" >' +
                    '<input type="checkbox" checked name="addcode" value="' + code + '">&nbsp;' + code + "</div>";
            $("#code").val("") ;

        }
        $("#code").select();
    }
 
</script>